package com.leet.string;

import java.lang.reflect.Array;
import java.util.Arrays;

public class LongestPalindrome {
    public int longestPalindrome(String s) {
        int[] map = new int[Integer.MAX_VALUE/2];
        Arrays.fill(map,0);
        for (int i = 0 ; i < s.length(); i++){
            map[s.charAt(i)]++;
        }
        int ans = 0 ,odd  = 0;
        for(int i = 0;i < map.length;i++){
            if(map[i]%2==0){
                ans+=map[i];
            }else{
                if(map[i] > odd){
                    odd = map[i];
                }
            }
        }
        ans += odd;
        return ans;
    }
}
